#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Math/Interpolations/Interpolation2D.h>
#pragma unmanaged 
#include <ql\experimental\inflation\polynomial2Dspline.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL::Math;
using namespace Cephei::QL::Math::Interpolations;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Experimental { namespace Inflation {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IPolynomial2DSpline
	public ref class CPolynomial2DSpline  : 
            public CInterpolation2D,
            public Cephei::QL::Experimental::Inflation::IPolynomial2DSpline
	{
	protected: 
		boost::shared_ptr<QuantLib::Polynomial2DSpline>* _ppPolynomial2DSpline;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::Polynomial2DSpline>* _phPolynomial2DSpline;
#endif
		Object^ _Polynomial2DSplineOwner;     // reference to object that manages the storage for this object
	internal:
        CPolynomial2DSpline (boost::shared_ptr<QuantLib::Polynomial2DSpline>& childNative, Object^ owner);
        CPolynomial2DSpline (QuantLib::Polynomial2DSpline& childNative, Object^ owner);
        CPolynomial2DSpline (CPolynomial2DSpline^ copy);
        CPolynomial2DSpline (PLATFORM::Type^ t);
#ifdef STRUCT
        CPolynomial2DSpline (QuantLib::Polynomial2DSpline childNative);
#endif       
#ifdef HANDLE
		CPolynomial2DSpline (QuantLib::Handle<QuantLib::Polynomial2DSpline>& childNative, Object^ owner);
		CPolynomial2DSpline (QuantLib::Handle<QuantLib::Polynomial2DSpline> childNative);
#endif
		virtual ~CPolynomial2DSpline ();
		!CPolynomial2DSpline ();

	internal:
		QuantLib::Polynomial2DSpline& GetReference ();
		boost::shared_ptr<QuantLib::Polynomial2DSpline>& GetShared ();
		QuantLib::Polynomial2DSpline* GetPointer ();
        void SetPolynomial2DSpline (boost::shared_ptr<QuantLib::Polynomial2DSpline> native)
        {
            if (_ppPolynomial2DSpline != NULL)
                delete _ppPolynomial2DSpline;
            _ppPolynomial2DSpline = new boost::shared_ptr<QuantLib::Polynomial2DSpline> (native);
            SetInterpolation2D (boost::dynamic_pointer_cast<QuantLib::Interpolation2D> (*_ppPolynomial2DSpline));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::Polynomial2DSpline>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Experimental::Inflation::IPolynomial2DSpline^>::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Inflation::IPolynomial2DSpline::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Inflation::IPolynomial2DSpline_Factory::typeid)]
	public ref class CPolynomial2DSpline_Factory sealed : public IPolynomial2DSpline_Factory
	{
	public:
    };
   
/*Cephei*/ } /*QL*/ } /*Experimental*/ } /*Inflation */}
